package com.phapli.versionchecking.preference;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by phapli on 2/7/2015.
 */
public class MyPrefs {
    private SharedPreferences prefs;
    SharedPreferences.Editor editor;

    public static final String TAG_JSON = "json";
    public static final String TAG_DATE = "date";


    public MyPrefs(Context context) {
        prefs = PreferenceManager.getDefaultSharedPreferences(context);
        editor = prefs.edit();
    }

    public String getJson() {
        return prefs.getString(TAG_JSON, "");
    }

    public void updateJson(String jsonStr) {
        editor.putString(TAG_JSON, jsonStr);
        editor.commit();
    }

    public Long getDateUpdate() {
        return prefs.getLong(TAG_DATE, 0);
    }

    public void updateDateUpdate(Long date) {
        editor.putLong(TAG_DATE, date);
        editor.commit();
    }

    public String getStringPref(String tag) {
        return prefs.getString(tag, "");
    }

    public void updateStringPref(String tag, String value) {
        editor.putString(tag, value);
        editor.commit();
    }

    public Boolean getBooleanPref(String tag) {
        return prefs.getBoolean(tag, false);
    }

    public void updateBooleanPref(String tag, Boolean value) {
        editor.putBoolean(tag, value);
        editor.commit();
    }

}
